package com.taxi.driver.module.recruit.selectcity;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.taxi.driver.R;
import com.taxi.driver.data.entity.ResourcesEntity;

import me.yokeyword.indexablerv.IndexableAdapter;

/**
 * Created by Curry on 2018/5/14.
 */

public class SelectCityAdapter extends IndexableAdapter<ResourcesEntity>
{
    private LayoutInflater mInflater;


    public SelectCityAdapter(Context context) {
        mInflater = LayoutInflater.from(context);
    }
    @Override
    public RecyclerView.ViewHolder onCreateTitleViewHolder(ViewGroup parent)
    {
        View view = mInflater.inflate(R.layout.item_index, parent, false);
        return new IndexVH(view);
    }

    @Override
    public RecyclerView.ViewHolder onCreateContentViewHolder(ViewGroup parent)
    {
        View view = mInflater.inflate(R.layout.item_index_city, parent, false);
        return new ContentVH(view);
    }

    @Override
    public void onBindTitleViewHolder(RecyclerView.ViewHolder holder, String indexTitle)
    { IndexVH vh = (IndexVH) holder;
        vh.tvIndex.setText(indexTitle);

    }

    @Override
    public void onBindContentViewHolder(RecyclerView.ViewHolder holder, ResourcesEntity entity)
    { ContentVH vh = (ContentVH) holder;
        vh.tvCity.setText(entity.getName());

    }



    private class IndexVH extends RecyclerView.ViewHolder {
        TextView tvIndex;


        IndexVH(View itemView) {
            super(itemView);
            tvIndex = (TextView) itemView.findViewById(R.id.tv_index);
        }
    }

    private class ContentVH extends RecyclerView.ViewHolder {
        TextView tvCity;

        ContentVH(View itemView) {
            super(itemView);
            tvCity = (TextView) itemView.findViewById(R.id.tv_city);
        }
    }
}
